#ifndef tk_mutex_h
#define tk_mutex_h

#include <QMutex>
#include <QMutexLocker>
#include <mutex>

namespace tk
{

class TkMutex
{
public:
    TkMutex(void)
    {
        //m_p_mutex = new QMutex(QMutex::Recursive);
		m_p_mutex = new std::recursive_mutex();
		
    }
    ~TkMutex(void)
    {
        delete m_p_mutex;
    }
public:
    void Lock()
    {
        m_p_mutex->lock();
    }
    void Unlock()
    {
        m_p_mutex->unlock();
    }
private:
    //QMutex * m_p_mutex;
	std::recursive_mutex * m_p_mutex;
};


class TkMutexLocker
{
public:
    TkMutexLocker(TkMutex & mutex)
    {
        m_plock = &mutex;
        m_plock->Lock();
    }
    ~TkMutexLocker(void)
    {
        m_plock->Unlock();;
    }
private:
    TkMutex * m_plock;
};


}//namespace tk


#endif // tk_mutex_h
